import { createStore } from 'vuex'
import createPersistedstate from 'vuex-persistedstate'
// v2: new Vuex.Store()
// v3: createStore

// 导入vuex的模块
import user from './modules/user.js'
import category from './modules/category.js'
import cart from './modules/cart.js'
export default createStore({
  state: {},
  getters: {},
  mutations: {},
  actions: {},
  modules: {
    user,
    category,
    cart
  },
  plugins: [
    // 插件
    createPersistedstate({
      key: 'rabbit-v3-143', // localStorage.setItem(key, value)
      paths: ['user', 'cart'] // 是一个数组，需要被自动持久化的模块的名字
    })
  ]
})
